<div ng-include src="'views/sidebar.html'"></div>
<section id="page-wrapper" ng-init="init()">
    <form class="form-inline">
        <div class="form-group">
          顶通类型：
          <select class="form-control" tabindex="2" style="margin:10px;" ng-model="topType" ng-change="search()">
            <option value="0" label="公告" selected></option>
            <option value="1" label="顶通"></option>
          </select>
          <button type="button" class="btn btn-success" ng-click="add()"
          style="top: 14px;right: 39px;position: absolute;z-index: 20;">新增</button>
        </div>
    </form>
    <hr>
    <div class="row">
        <div class="col-md-12">
            <pagination boundary-links="true" max-size="20" items-per-page="25" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;" ng-change="pageChanged()"></pagination>
        </div>
        <div class="col-md-12">
            <table class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th>顶通类型</th>
                        <th>页面类型</th>
                        <th>背景色</th>
                        <th>公告内容</th>
                        <th>落地连接</th>
                        <th>开始时间</th>
                        <th>结束时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="page in pages">
                        <td>{{getTopType(page.topType)}}</td>
                        <td>{{getType(page.displayPage)}}</td>
                        <td><div style="background:{{page.background}};display: block; height: 30px; width: 100%"></div></td>
                        <td>{{page.notice}}</td>
                        <td>{{page.url}}</td>
                        <td>{{page.startTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
                        <td>{{page.endTime | date : 'yyyy-MM-dd HH:mm:ss'}}</td>
                        <td>
                          <button type="button" class="btn btn-default" ng-click="open(page)">编辑</button>
                          </td>
                </tbody>
            </table>
        </div>
        <div class="col-md-12">
            <pagination boundary-links="true" max-size="20" items-per-page="25" total-items="totalItems" ng-model="currentPage" class="pagination-sm" previous-text="&lsaquo;" next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;" ng-change="pageChanged()"></pagination>
        </div>
    </div>
</section>
<script type="text/ng-template" id="header.config.add.html">
  <input type="file" style="display:none;" id="fileuploader"/>
  <form class="form-horizontal" name="myForm" ng-init="init()">
    <div class="modal-header">
      <h3 class="modal-title">顶通详细信息</h3>
    </div>
    <div class="modal-body">
      <div class="form-group">
        <label class="col-sm-2 control-label">顶通类型</label>
        <div class="col-sm-10">
          <select class="form-control" ng-model="page.topType" ng-change="changeTopType(page.topType)">
             <option value="0" label="公告" selected></option>
             <option value="1" label="顶通"></option>
          </select>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">顶通类型</label>
        <div class="col-sm-10">
          <label><input name="pageType" type="checkbox" value="1" />首页 </label>
          <label><input name="pageType" type="checkbox" value="2" />频道页 </label>
          <label><input name="pageType" type="checkbox" value="3" />搜索&店铺 </label>
          <label><input name="pageType" type="checkbox" value="4" />活动页 </label>
          <label><input name="pageType" type="checkbox" value="5" />个人中心 </label>
          <label><input name="pageType" type="checkbox" value="6" />订单 </label>
          <label><input name="pageType" type="checkbox" value="7" />详情页&购物车 </label>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">背景色</label>
        <div class="col-sm-10">
          <input type="color" class="form-control" ng-model="page.background">
        </div>
      </div>
      <div class="form-group" ng-if="page.topType == 0">
        <label class="col-sm-2 control-label">公告内容</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" ng-model="page.notice">
        </div>
      </div>
      <div ng-if="page.topType == 1">
        <div class="form-group">
          <label class="col-sm-2 control-label">顶通落地连接</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" ng-model="page.url">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">图片连接</label>
          <div class="col-sm-10">
            <div class="input-group">
              <input type="text" class="form-control" ng-model="page.imgUrl">
              <span class="input-group-btn">
                <button class="btn btn-default" ng-click="changeFile(1)" tabindex="0">
                <i class="glyphicon glyphicon-folder-open"></i>
                </button>
                <button class="btn btn-success" tabindex="0" ng-if="isCompleted == true">
                <i class="glyphicon glyphicon-ok"></i>
                </button>
              </span>
            </div>
          </div>
        </div>
        <div class="form-group">
           <label class="col-sm-2 control-label">动作类型</label>
          <div class="col-sm-10">
            <select class="form-control" ng-model="page.cascadeType">
              <option value="0" label="顶通小图">
              <option value="1" label="顶通下拉大图">
              <option value="2" label="弹出类型">
            </select>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">大图连接</label>
          <div class="col-sm-10">
            <div class="input-group">
              <input type="text" class="form-control" ng-model="page.bigImgUrl">
              <span class="input-group-btn">
                <button class="btn btn-default" ng-click="changeFile(2)" tabindex="0">
                <i class="glyphicon glyphicon-folder-open"></i>
                </button>
                <button class="btn btn-success" tabindex="0" ng-if="isCompletedB == true">
                <i class="glyphicon glyphicon-ok"></i>
                </button>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">开始时间</label>
        <div class="col-sm-10">
          <div class='input-group date' ng-init="initTime()">
            <input type='text' class="form-control datetimepicker datetimepicker1" ng-model="page.startTime" ng-blur="dateChange(1)" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
          </div>
        </div>

      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">结束时间</label>
        <div class="col-sm-10">
          <div class='input-group date' ng-init="initTime()">
            <input type='text' class="form-control datetimepicker datetimepicker2" ng-model="page.endTime" ng-blur="dateChange(2)" />
                    <span class="input-group-addon">
                        <span class="glyphicon glyphicon-calendar"></span>
                    </span>
          </div>
        </div>

      </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-success" ng-disabled="myForm.$invalid" ng-click="save(page)" type="submit">新增</button>
        <button class="btn btn-default" ng-click="cancel()">取消</button>
      </div>
    </div>
  </form>
</script>
<script type="text/ng-template" id="header.config.edit.html">
  <input type="file" style="display:none;" id="fileuploader"/>
  <form class="form-horizontal" name="myForm">
    <div class="modal-header">
      <h3 class="modal-title">顶通详细信息</h3>
    </div>
    <div class="modal-body">
      <div class="form-group">
        <label class="col-sm-2 control-label">顶通类型</label>
        <div class="col-sm-10">
        <select class="form-control" ng-model="page.topType">
           <option value="0" label="公告"></option>
           <option value="1" label="顶通"></option>
        </select>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">顶通类型</label>
        <div class="col-sm-10">
        <select class="form-control" ng-model="page.displayPage">
           <option value="1" label="首页" selected></option>
           <option value="2" label="频道页"></option>
           <option value="3" label="搜索&店铺"></option>
           <option value="4" label="活动页"></option>
           <option value="5" label="个人中心"></option>
           <option value="6" label="订单"></option>
           <option value="7" label="详情页&购物车"></option>
        </select>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">背景色</label>
        <div class="col-sm-10">
        <input type="color" class="form-control" ng-model="page.background">
        </div>
      </div>
      <div class="form-group" ng-if="page.topType == 0">
        <label class="col-sm-2 control-label">公告内容</label>
        <div class="col-sm-10">
        <input type="text" class="form-control" ng-model="page.notice">
        </div>
      </div>
      <div ng-if="page.topType == 1">
        <div class="form-group">
          <label class="col-sm-2 control-label">顶通落地连接</label>
          <div class="col-sm-10">
          <input type="text" class="form-control" ng-model="page.url">
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">图片连接</label>
          <div class="col-sm-10">
            <div class="input-group">
              <input type="text" class="form-control" ng-model="page.imgUrl">
              <span class="input-group-btn">
                <button class="btn btn-default" ng-click="changeFile(1)" tabindex="0">
                <i class="glyphicon glyphicon-folder-open"></i>
                </button>
                <button class="btn btn-success" tabindex="0" ng-if="isCompleted == true">
                <i class="glyphicon glyphicon-ok"></i>
                </button>
              </span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">动作类型</label>
          <div class="col-sm-10">
          <select class="form-control" ng-model="page.cascadeType">
            <option value="0" label="横条">
            <option value="1" label="横条下拉">
            <option value="2" label="弹出类型">
          </select>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">大图连接</label>
          <div class="col-sm-10">
            <div class="input-group">
              <input type="text" class="form-control" ng-model="page.bigImgUrl">
              <span class="input-group-btn">
                <button class="btn btn-default" ng-click="changeFile(2)" tabindex="0">
                <i class="glyphicon glyphicon-folder-open"></i>
                </button>
                <button class="btn btn-success" tabindex="0" ng-if="isCompletedB == true">
                <i class="glyphicon glyphicon-ok"></i>
                </button>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">开始时间</label>
        <div class="col-sm-10">
          <div class='input-group date' ng-init="initTime()">
            <input type='text' class="form-control datetimepicker datetimepicker1" ng-model="page.startTime" ng-blur="dateChange(1)" />
                  <span class="input-group-addon">
                      <span class="glyphicon glyphicon-calendar"></span>
                  </span>
          </div>
        </div>

      </div>
      <div class="form-group">
        <label class="col-sm-2 control-label">结束时间</label>
        <div class="col-sm-10">
          <div class='input-group date' ng-init="initTime()">
            <input type='text' class="form-control datetimepicker datetimepicker2" ng-model="page.endTime" ng-blur="dateChange(2)" />
                  <span class="input-group-addon">
                      <span class="glyphicon glyphicon-calendar"></span>
                  </span>
          </div>
        </div>

      </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-success" ng-disabled="myForm.$invalid" ng-click="save(page)" type="submit">修改</button>
        <button class="btn btn-default" ng-click="cancel()">取消</button>
      </div>
    </div>
  </form>
</script>
